package com.jinzhuo.music.service;

import com.jinzhuo.music.dao.ListSongMapper;
import com.jinzhuo.music.domain.ListSong;
import com.jinzhuo.music.domain.Song;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 歌单包含歌曲列表service
 */
@Service
public class ListSongServiceImpl implements ListSongService {
    @Autowired
    private ListSongMapper listSongMapper;

    /**
     * 添加
     *
     * @param pojo
     */
    @Override
    public boolean addListSong(ListSong pojo) {
        return listSongMapper.addListSong(pojo)>0;
    }

    /**
     * 修改
     *
     * @param pojo
     */
    @Override
    public boolean updateListSong(ListSong pojo) {
        return listSongMapper.updateListSong(pojo)>0;
    }

    /**
     * 删除
     *
     * @param id
     */
    @Override
    public boolean deleteListSong(Integer id) {
        return listSongMapper.deleteListSong(id)>0;
    }

    /**
     * 根据歌曲id和歌单id删除
     *
     * @param songId
     * @param songListId
     */
    @Override
    public boolean deleteBySongIdAndSongListId(Integer songId, Integer songListId) {
        return listSongMapper.deleteBySongIdAndSongListId(songId,songListId)>0;
    }

    /**
     * 根据主键查询单个对象
     *
     * @param id
     */
    @Override
    public ListSong getListSong(Integer id) {
        return listSongMapper.getListSong(id);
    }

    /**
     * 查询所有歌曲
     */
    @Override
    public List<ListSong> queryAllListSong() {
        return listSongMapper.queryAllListSong();
    }

    /**
     * 根据歌单id查询歌曲
     *
     * @param songListId
     */
    @Override
    public List<ListSong> querySongBySongListId(Integer songListId) {
        return listSongMapper.querySongBySongListId(songListId);
    }
}
